from YK_liushuai.Page.Page import Page
from selenium.webdriver.common.by import By
import time
class Page1(Page):
    # 点击团购
    tunagou_loc=(By.XPATH,'/html/body/div[3]/div[2]/ul/li[5]/a')
    def tunagou(self):
        self.click(self.tunagou_loc)
    # 选择商品
    shangp_loc=(By.XPATH,'//img[@src="/uploads/images/20250819/c50d806e1b9e48e57ea1bdbe3dfb130c.png"]')
    def shangp(self):
        self.click(self.shangp_loc)
#     断言商品华为p90pro
    dy1_loc=(By.XPATH,'/html/body/div[4]/a[3]')
    def dy1(self):
        return self.text(self.dy1_loc)
#     点击购买按钮
    goumai_loc=(By.ID,'buy-cart')
    def goumai(self):
        self.click(self.goumai_loc)
#     选择收货地址
    dizhi_loc=(By.CSS_SELECTOR,'.radio-select-btn')
    def dizhi(self):
        self.click(self.dizhi_loc)
#     断言商品总金额
    dy2_loc=(By.ID,'order-amount')
    def dy2(self):
        return self.text(self.dy2_loc)
#     点击下一步
    xiayibu_loc=(By.ID,'order-button')
    def xiayibu(self):
        self.click(self.xiayibu_loc)
#     断言订单完成
    dy3_loc=(By.XPATH,'/html/body/div[4]/div[1]/a[2]')
    def dy3(self):
        return self.text(self.dy3_loc)


    def test_a3mall_tuangou(self):
        self.test_a3mall_login()
        self.tunagou()
        self.shangp()
        self.dy1()
        print("断言1：商品华为p90pro：",self.dy1())
        time.sleep(3)
        self.goumai()
        self.dizhi()
        self.dy2()
        print("断言2：商品金额：",self.dy2())
        time.sleep(3)
        self.xiayibu()
        self.dy3()
        print("断言3：订单完成：",self.dy3())
        time.sleep(5)

